local sk__luocha = fk.CreateSkill {

  name = "sk__luocha",

  tags = { Skill.Compulsory, },

}



sk__luocha:addEffect(fk.GameStart, {
  name = "sk__luocha",
  anim_type = "special",
  frequency = Skill.Compulsory,
  events = {fk.GameStart, fk.EnterDying},
  can_trigger = function(self, event, target, player, data)
    if player:hasSkill(sk__luocha.name) then
      if event == fk.GameStart then
        return true
      elseif event == fk.EnterDying then
        return target ~= player
      end
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local n = 1
    if event == fk.GameStart then
      n = 3
    elseif event == fk.EnterDying then
      player:drawCards(2, sk__luocha.name)
    end
    if player.dead then return end
    local skills = {}
    for _, general in ipairs(Fk:getAllGenerals()) do
      for _, skill in ipairs(general:getSkillNameList()) do
        if string.find(Fk:translate(":"..skill, "zh_CN"), "【杀】") and not player:hasSkill(skill, true) then
          table.insertIfNeed(skills, skill)
        end
      end
    end
    if #skills > 0 then
      skills = table.random(skills, n)
      room:handleAddLoseSkills(player, skills, nil, true, false)
    end
  end,
})
sk__luocha:addEffect(fk.EnterDying, {
  name = "sk__luocha",
  anim_type = "special",
  frequency = Skill.Compulsory,
  events = {fk.GameStart, fk.EnterDying},
  can_trigger = function(self, event, target, player, data)
    if player:hasSkill(sk__luocha.name) then
      if event == fk.GameStart then
        return true
      elseif event == fk.EnterDying then
        return target ~= player
      end
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local n = 1
    if event == fk.GameStart then
      n = 3
    elseif event == fk.EnterDying then
      player:drawCards(2, sk__luocha.name)
    end
    if player.dead then return end
    local skills = {}
    for _, general in ipairs(Fk:getAllGenerals()) do
      for _, skill in ipairs(general:getSkillNameList()) do
        if string.find(Fk:translate(":"..skill, "zh_CN"), "【杀】") and not player:hasSkill(skill, true) then
          table.insertIfNeed(skills, skill)
        end
      end
    end
    if #skills > 0 then
      skills = table.random(skills, n)
      room:handleAddLoseSkills(player, skills, nil, true, false)
    end
  end,
})

return sk__luocha